package com.huitu.whht.base.core.api.geo.wiust;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.base.core.api.geo.wiust.entities.GeoWiustQo;
import com.huitu.whht.base.core.api.geo.wiust.service.IGeoWiustCoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 说明: 取用水测站空间信息,表名称: GEO_WIU_5T <br/>
 * 日期: 2018-09-04
 *
 * @author ZhangAY
 */
@Component
@SzyCoreApiResource
@Path("geo/wiust")
public class GeoWiustCoreResource extends AbstractApiResource {

    private static final Logger logger = LoggerFactory.getLogger(GeoWiustCoreResource.class);

    private static final String UUID = "d5f76b8d-fc1b-41c7-b639-c0c66061f165";
    @Autowired
    @SzyCoreApiService
    IGeoWiustCoreService geoWiustCoreService;

    @Override
    public String getUUID() {
        return UUID;
    }

    /**
     * @api {get} geo/wiu/{wiuCd:\\w{9}} [R]根据主键查询
     * @apiDescription 根据主键查询GEO_WIU_5T取用水户空间信息数据
     * @apiName select by primary key
     * @apiGroup GEO_S3_0015-取用水户空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/wiu/01112771X
     * @apiParam {String}         wiuCd              【必须】取用水户代码
     * @apiSuccess {String}         wiuCd              取用水户代码
     * @apiSuccess {String}         wiuNm              取用水户名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "wiuCd": "177605611",
     * "wiuNm": "国电长源第一发电有限责任公司",
     * "lgtd": 114.433288888889,
     * "lttd": 30.6326805555556,
     * "shape": "POINT (114.433288888889 30.6326805555556)",
     * "rowId": 1
     * }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{wiustCd:\\w{10}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("wiustCd") String wiustCd) {
        logger.info("根据主键查询 取用水测站空间信息,参数 wiustCd:{}", wiustCd);
        return Response.ok(ApiResultBuilder.create(this, geoWiustCoreService.selectByPrimaryKey(wiustCd))).build();
    }


    /**
     * @api {post} geo/wiu/list [R]根据条件查询(含空间信息)
     * @apiDescription 根据条件查询GEO_WIU_5T取用水户空间信息数据(含空间信息)
     * @apiName select by filter
     * @apiGroup GEO_S3_0015-取用水户空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/wiu/list
     * @apiParam {List(String)}   wiuCdList          (数组)取用水户代码
     * @apiParam {String}         wiuCd              取用水户代码
     * @apiParam {String}         wiuNm              取用水户名称
     * @apiParam {String}         lrNm               法人代表
     * @apiParam {List(String)}   tradTpList         (数组)行业类别
     * @apiParam {List(String)}   ecoTpList          (数组)经济类型
     * @apiParam {List(String)}   monGList           (数组)监控级别
     * @apiParam {List(String)}   wiuTpList          (数组)取水类型
     * @apiParam {String}         web                网址
     * @apiParam {String}         eMail              邮箱
     * @apiParam {String}         addr               地址
     * @apiParam {String}         zip                邮编
     * @apiParam {String}         tel                办公室电话
     * @apiParam {String}         fax                传真号码
     * @apiParam {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam {String}         nt                 备注
     * @apiParam {List(String)}   adlCdList          (数组)归属行政层级代码
     * @apiParam {String}         adlCd              归属行政层级代码
     * @apiParam {List(String)}   isHiLevList        (数组)是否为高耗水行业
     * @apiParam {List(String)}   isVimpList         (数组)是否重点监控取用水户
     * @apiParam {List(String)}   supOrgCdList       (数组)上级主管单位代码
     * @apiParam {String}         supOrgCd           上级主管单位代码
     * @apiParam {String}         wiuCd              【必须】取用水户代码
     * @apiSuccess {String}         wiuCd             取用水户代码
     * @apiSuccess {String}         wiuNm             取用水户名称
     * @apiSuccess {String}         lgtd              经度
     * @apiSuccess {String}         lttd              纬度
     * @apiSuccess {String}         shape             空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "wiuCd": "177605611",
     * "wiuNm": "国电长源第一发电有限责任公司",
     * "lgtd": 114.433288888889,
     * "lttd": 30.6326805555556,
     * "shape": "POINT (114.433288888889 30.6326805555556)"
     * },
     * {
     * "wiuCd": "111415885",
     * "wiuNm": "监利县柘木乡中心自来水厂",
     * "lgtd": 113.093125,
     * "lttd": 29.5690055555556,
     * "shape": "POINT (113.093125 29.5690055555556)"
     * }]
     * }
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "wiuCd": "177605611",
     * "wiuNm": "国电长源第一发电有限责任公司",
     * "lgtd": 114.433288888889,
     * "lttd": 30.6326805555556,
     * "shape": "POINT (114.433288888889 30.6326805555556)",
     * "rowId": 1
     * },
     * {
     * "wiuCd": "111415885",
     * "wiuNm": "监利县柘木乡中心自来水厂",
     * "lgtd": 113.093125,
     * "lttd": 29.5690055555556,
     * "shape": "POINT (113.093125 29.5690055555556)",
     * "rowId": 2
     * }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(GeoWiustQo filter) {
        PageUtils.startPageFromRang();
        logger.info("根据条件查询 取用水测站空间信息,参数 GeoWiustQo:{}", filter);
        return Response.ok(ApiResultBuilder.create(this, geoWiustCoreService.selectList(filter))).build();
    }
}
